fix: pass total_tokens for SSM seq_idx in packed sequences - #3484
Merged
Conversation
Without total_tokens, PackedSeqParams.__post_init__ skips seq_idx computation, causing Mamba/SSM state to bleed across sequence boundaries in varlen (packed sequence) training. This affects all hybrid SSM models (Nemotron Nano, NemotronH, Nemotron Nano V2, Nemotron 3 Super), not just Nemotron Nano. Fixes #3474 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com>
yaoyu-33
force-pushed
the
fix/pass-total-tokens-for-ssm-seq-idx
branch
from
April 22, 2026 21:44
2a2e10c to
5e50ac2
Compare
5 tasks
Contributor
|
/ok to test 5e50ac2 |
Contributor
QA RCCA Analysis1. Fix Reference
2. Root Cause
3. Trigger Configuration
4. Nature of the BugClassification: CODE BUG - SSM state corruption in packed sequence training 5. Existing Test CoverageIn Fix PR: YES - 1 test file modified:
In NMFW Tests: Not specifically covering SSM packed sequence scenarios 6. Coverage Assessment
7. New Regression TestNOT NEEDED - Fix PR includes unit tests for 8. ConclusionVerdict: ADEQUATE COVERAGE - Fix PR includes unit tests verifying total_tokens handling for SSM models. |
3 tasks
vasunvidia
pushed a commit
to vasunvidia/Megatron-Bridge
that referenced
this pull request
Jun 10, 2026
…Mo#3484) Signed-off-by: yaoyu-33 <yaoyu.094@gmail.com> Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Signed-off-by: Vasudevan Rengasamy <vrengasamy@nvidia.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
total_tokensthroughget_packed_seq_params()toPackedSeqParams, enablingseq_idxgeneration for hybrid SSM/Mamba models during varlen (packed sequence) trainingseq_idxremainsNoneand SSM state bleeds across sequence boundaries in packed batches, corrupting trainingtokens.size(1)on the first PP stage andlabels.size(1)on the last PP stage (matching upstream Megatron-LMpretrain_mamba.py)total_tokensdefaults toNonefor non-SSM modelsFixes #3474
Test plan
get_packed_seq_paramscoveringtotal_tokens→seq_idxgeneration, backward compat (seq_idx=Nonewithouttotal_tokens), and thecu_seqlens_unpaddedpathseq_idxgenerated whentotal_tokensabsent)🤖 Generated with Claude Code